package fun.werfamily.wf.user.core.controller;

import fun.werfamily.wf.base.vo.Result;
import fun.werfamily.wf.user.core.domain.dto.req.GeoAddressReqDTO;
import fun.werfamily.wf.user.core.domain.dto.resp.GeoAddressDTO;
import fun.werfamily.wf.user.core.domain.service.IGeoAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags = "省市区地址模块")
@RestController
@RequestMapping("/api/geo/address")
public class GeoAddressApiController {

    @Resource
    private IGeoAddressService iGeoAddressService;

    @ApiOperation("根据地址编码获取下一级所有地址信息")
    @PostMapping("/listByGeoCode")
    public Result<List<GeoAddressDTO>> listAllChildByGeoCode(@RequestBody GeoAddressReqDTO geoAddressReqDTO) {
        log.info("根据地址编码获取下一级所有地址信息，入参{}", geoAddressReqDTO);
        return Result.success(iGeoAddressService.listAllChildByGeoCode(geoAddressReqDTO));
    }
}
